<template>
  <div class="pointsoperateBranch">
    <topBar :title="title"></topBar>
    <div class="echarts">
      <div class="bot">
        <div v-for="(item, index) in lineDatas" :key="index">
          <lineEcharts
            :id="'lineechart' + index"
            :lineData="item"
          ></lineEcharts>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import topBar from "./topBar";
import lineEcharts from "../showEchart/lineEcharts";
import { stepSubmap } from "@/api/codeIncome/analysis";
export default {
  name: "pointsoperateBranch",
  components: {
    topBar,
    lineEcharts,
  },
  props: {
    searchData: {
        type: Object,
        default: {},
    },
  },
  watch: {
    searchData: {
        handler(newName) {
            this.getlineData()
        },
        deep: true,
    },
  },
  data() {
    return {
      title: "台阶收入 – 分经营单元（分局）",
      lineDatas: [],
    };
  },
  created() {},
  mounted() {
    this.getlineData();
  },
  methods: {
    getlineData() {
      this.lineDatas = []
      stepSubmap({
        cycleValue: this.searchData.acctMonth,
        areaId: this.searchData.areaId,
        flag: 3
      }).then((res) => {
        if (res.code == 200) {
          let data = res.data;
          let arr = [];
          data.forEach((item) => {
            let obj = {};
            obj["title"] = item.name;
            let lastdataArr = [];
            let indataArr = [];
            item.data.forEach((it) => {
              lastdataArr.push(it.indexValueTb);
              indataArr.push(it.indexValue);
            });
            let indata = [];
            indataArr.forEach((item) => {
              if (item != undefined && item != null && item != 0) {
                indata.push(item);
              } else {
                indata.push('');
              }
            });
            obj["lastdata"] = lastdataArr;
            obj["indata"] = indata;
            arr.push(obj);
          });
          this.lineDatas = arr
        }
      });
    },
  },
};
</script>
<style scoped>
.pointsoperateBranch {
  box-sizing: border-box;
  padding: 20px;
  box-shadow: 0px 0px 10px 1px rgb(0 0 0 / 15%);
}
</style>
<style scoped lang="scss">
.pointsoperateBranch {
  margin-top: 20px;
  .echarts {
    width: 100%;
    height: auto;
    .bot {
      display: flex;
      flex-wrap: wrap;
      justify-content: flex-start;
      > div {
        width: 33.33%;
        height: 200px;
      }
    }
  }
}
</style>
